package com.agenda.server.recebedores;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import com.agenda.comum.ObjectRecebedorInformacao;
import com.agenda.controller.VideoController;
import com.agenda.model.RespostaRequisicao;
import com.agenda.model.Sala;

public class SolicitarVideoRecebedor extends ObjectRecebedorInformacao {

	private RespostaRequisicao resposta;
	private Boolean liberou;

	@Override
	public void receber(ObjectInputStream objectInput) throws Exception {
		Sala sala = (Sala) objectInput.readObject();
		try {

			liberou = VideoController.getINSTANCE().reservarSalaVideo();

			resposta = new RespostaRequisicao(false, "");
		} catch (Exception e) {
			resposta = new RespostaRequisicao(true, e.getMessage());
		}
	}

	@Override
	protected RespostaRequisicao getReposta() {
		return resposta;
	}

	@Override
	protected void responder(OutputStream outputStream) throws Exception {
		ObjectOutputStream objOutput = new ObjectOutputStream(sck.getOutputStream());
		objOutput.writeObject(liberou);
	}
}
